package cn.ococci.dm.Main.Core;

import cn.ococci.dm.Main.Tools.ThreadTool;

/**
 * Created by cyan on 16/1/27.
 * 打开红外
 */
public class CommandOpenInfrared implements CommandExecute {

    private SocketCommand doorCommand;
    private CommandType type = CommandType.OPEN_INFRARED;
    boolean isOne;

    /**
     * 设置开关
     * @param doorCommand
     * @param isOne
     */
    public CommandOpenInfrared(SocketCommand doorCommand, boolean isOne) {
        this.doorCommand = doorCommand;
        this.isOne = isOne;
    }

    /**
     * 获取状态
     * @param doorCommand
     * @param type
     */
    public CommandOpenInfrared(SocketCommand doorCommand,CommandType type) {
        this.doorCommand = doorCommand;
        this.type = type;
    }


    @Override
    public void execute() {
        ThreadTool.runOnBgThread(new Runnable() {
            @Override
            public void run() {

                if(type == CommandType.OPEN_INFRARED){

                    doorCommand.openInfrared(type, isOne);

                }else{

                    doorCommand.getInfraredStatus(type);
                }
            }
        });
    }
}
